﻿/*===================================================
* CLR版本  : 4.0.30319.42000 
* 类名称   : BuildHelper
* 文 件 名 : BuildHelper 
* 类描述   :
* 创建人   : oream
* 创建时间 : 2018/2/19 22:28:30
* 修改人   : 
* 修改时间 :
* 版本： @version 1.0
=====================================================*/

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEditor;
using UnityEngine;

namespace Model.AssetBundle.Holper
{
  public enum EnumBuildPlatform
  {
    Windows,
    IOS,
    Android
  }
  public static class BuildHelper
  {
    public static void BuildAssetBundle(EnumBuildPlatform buildPlatform)
    {
      switch (buildPlatform)
      {
        case EnumBuildPlatform.Windows:
          Build(Application.dataPath + "/StreamingAssets/Release/Windows", BuildTarget.StandaloneWindows);
          break;
        case EnumBuildPlatform.IOS:
          Build(Application.dataPath + "/StreamingAssets/Release/IOS", BuildTarget.iOS);
          break;
        case EnumBuildPlatform.Android:
          Build(Application.dataPath + "/StreamingAssets/Release/Android", BuildTarget.Android);
          break;
        default:
          break;
      }
    }

    private static void Build(string path, BuildTarget buildTarget)
    {
      if (!Directory.Exists(path))
      {
        Directory.CreateDirectory(path);
      }

      BuildPipeline.BuildAssetBundles(path, BuildAssetBundleOptions.None, buildTarget);
      AssetDatabase.Refresh();
    }


    public static void ClearBundleFile(EnumBuildPlatform buildPlatform)
    {

    }

  }
}
